﻿CREATE PROCEDURE [dbo].[proc_Finance_Outlay_GetlistTotal]
	(
		@CompanyId int,
		@StartDate nvarchar(10),
		@EndDate nvarchar(10),
		@PaymentTypeId int,
		@BankId int,
		@CateOneId int,
		@CateTwoId int,
		@SubjectId int,
		@Stext nvarchar(50)
	)
AS
begin
	
	Select Count(Id),ISNULL(Sum(OutlayPrice),0)
	From Finance_Outlay R 
	Where (@CompanyId=0 Or R.CompanyId=@CompanyId)
	and Convert(nchar(10),R.TradeDate,120) between @StartDate and @EndDate
	and (@PaymentTypeId=0 Or R.PaymentTypeId=@PaymentTypeId)
	and (@BankId=0 Or R.BankId=@BankId)
	and (@CateOneId=0 Or R.CateOneId=@CateOneId) and (@CateTwoId=0 Or CateTwoId=@CateTwoId)
	and (@SubjectId=0 Or R.SubjectId=@SubjectId)
	and (@Stext='' Or R.Summary like '%'+ @Stext +'%')	
end